package com.jonlin.springboottest.utils.excel;

/**
 * FileName: ExcelEntity.java
 * Author:   jonlin
 * Date:     2018-06-27 23:43
 * Description:
 */

import com.jonlin.springboottest.annotation.OutputExcel;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

/**
 * excel基础类
 */
@Data
public class ExcelEntity {

    /** 标题 */
    private String title;
    /** 排序 */
    private int sort;
    /** 属性名称 */
    private String fieldName;
    /** 参数类型 */
    private Class classType;

    private static String getStr = "get";

    private static String setStr = "set";

    public ExcelEntity(OutputExcel excel, String fieldName){
        this.fieldName = getStr + upperCase(fieldName);
        this.title = StringUtils.isBlank(excel.title())?"":excel.title();
        this.sort = excel.sort();
    }

    /**
     * 首字母大写
     */
    public static String upperCase(String str) {
        char[] ch = str.toCharArray();
        if (ch[0] >= 'a' && ch[0] <= 'z') {
            ch[0] = (char) (ch[0] - 32);
        }

        return new String(ch);
    }

//    public ExcelEntity(ImportExcel excel, String fieldName, Class classType){
//        this.fieldName = setStr + StringUtil.upperCase(fieldName);
//        this.classType = classType;
//        this.sort = excel.value()+"";
//    }

    }